home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue53 / Clinic / QRPrintersForm.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1999-11-04  |  1.3 KB  |  55 lines

  1. unit QRPrintersForm;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls, Db, DBTables, QuickRpt, Qrctrls;
  8.  
  9. type
  10.   TMainForm = class(TForm)
  11.     btnPrintReport: TButton;
  12.     lstPrinters: TListBox;
  13.     Label1: TLabel;
  14.     procedure FormCreate(Sender: TObject);
  15.     procedure lstPrintersClick(Sender: TObject);
  16.     procedure btnPrintReportClick(Sender: TObject);
  17.   private
  18.     { Private declarations }
  19.   public
  20.     { Public declarations }
  21.   end;
  22.  
  23. var
  24.   MainForm: TMainForm;
  25.  
  26. implementation
  27.  
  28. uses
  29.   Printers, QRPrintersReport;
  30.  
  31. {$R *.DFM}
  32.  
  33. procedure TMainForm.FormCreate(Sender: TObject);
  34. begin
  35.   //Get list of printers displayed in the listbox on the form
  36.   lstPrinters.Items := Printer.Printers;
  37.   //Highlight default printer
  38.   lstPrinters.ItemIndex := Printer.PrinterIndex
  39. end;
  40.  
  41. procedure TMainForm.lstPrintersClick(Sender: TObject);
  42. begin
  43.   //Record chosen printer as new current printer and as QuickReports target
  44.   Printer.PrinterIndex := lstPrinters.ItemIndex;
  45.   ReportForm.QuickRep1.PrinterSettings.PrinterIndex := lstPrinters.ItemIndex;
  46. end;
  47.  
  48. procedure TMainForm.btnPrintReportClick(Sender: TObject);
  49. begin
  50.   //Print report on newly selected printer
  51.   ReportForm.QuickRep1.Print
  52. end;
  53.  
  54. end.
  55.